<template>
	<view>
		<view class="mainpadding flexbetween" @click="jumpurl('/pages/system/system?type=1')">
			<view class="main_size hei_text">關於我們</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="mainpadding flexbetween" @click="jumpurl('/pages_mine/myPenalize')">
			<view class="main_size hei_text">我的處罰</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="mainpadding flexbetween" @click="jumpurl('/pages_mine/familiarProblem')">
			<view class="main_size hei_text">常見問題</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="mainpadding flexbetween" @click="clearcache">
			<view class="main_size hei_text">清除緩存</view>
			<view class="flexright">
				<view class="xiaohui margin_right">{{fileSizeString}}</view>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<view class="posibottom mainpadding" style="bottom: 0;">
			<view class="submitbtn">退出登錄</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				fileSizeString:"",
			}
		},
		onLoad() {
			this.formatSize()
		},
		methods: {
			clearcache() {
				httpRequest.modal('提示', '確定清除缓存吗？', true, (res) => {
					if (res) {
						let that = this;
						uni.clearStorageSync();
						//重新獲取并显示清除后的缓存大小
						that.formatSize();
						httpRequest.toast('清除成功')
					}
				})
			},
			//缓存计算
			formatSize() {
				let that = this;
				uni.getStorageInfo({
					success(res) {
						let size = res.currentSize;
						if (size < 1024) {
							that.fileSizeString = size + ' B';
						} else if (size / 1024 >= 1 && size / 1024 / 1024 < 1) {
							that.fileSizeString = Math.floor(size / 1024 * 100) / 100 + ' KB';
						} else if (size / 1024 / 1024 >= 1) {
							that.fileSizeString = Math.floor(size / 1024 / 1024 * 100) / 100 + ' M';
						}
					}
				})
			},
			jumpurl(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style>

</style>